import App from './App'
import filter from './filter/filter.js'
import systemInfo from "@/mixins/systemInfo.js";
import go from "@/mixins/go.js";
import goBack from "@/mixins/goBack.js"
import img from "@/mixins/img.js"
// import Vconsole from 'vconsole';
// new Vconsole();

import uView from '@/uni_modules/uview-ui'
Vue.use(uView)

// #ifndef VUE3
import Vue from 'vue'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'

dayjs.locale('zh-cn')

Vue.mixin(img)
Vue.mixin(goBack)
Vue.mixin(systemInfo)
Vue.mixin(go)
Vue.config.productionTip = false
App.mpType = 'app'
Object.keys(filter).forEach(key => Vue.filter(key, filter[key]))
const app = new Vue({
	...App
})
app.$mount()
// #endif

/**
 * 格式化时间
 * @param fmt
 * @returns {void | string}
 * @constructor
 */
Date.prototype.format = function(fmt) {
	var o = {
		"M+": this.getMonth() + 1, //月份
		"D+": this.getDate(), //日
		"H+": this.getHours(), //小时
		"m+": this.getMinutes(), //分
		"s+": this.getSeconds(), //秒
		"q+": Math.floor((this.getMonth() + 3) / 3), //季度
		"S": this.getMilliseconds() //毫秒
	};
	if (/(Y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((
			"00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import VueClipboard from 'vue-clipboard2'

Object.keys(filter).forEach(key => Vue.filter(key, filter[key]))
Vue.use(VueClipboard)

export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}

// #endif